package se.webbzon.boltzmann.game.sequence;

import se.webbzon.boltzmann.game.object.dialogue.AbstractDialogue;
import se.webbzon.boltzmann.game.object.dialogue.ChoiceDialogue;
import se.webbzon.boltzmann.game.object.dialogue.ChoiceDialogueListener;

public class ChoiceDialogueSequenceNode extends AbstractDialogueSequenceNode implements ChoiceDialogueListener {

	// An array containing the branches of this node
	private SequenceNode[] branches;
	
	/*============================================================
	Constructors
	============================================================*/
	
	public ChoiceDialogueSequenceNode(Sequence sequence, ChoiceDialogue dialogue) {
		super(sequence, dialogue);
		dialogue.addListener(this);
	}
	
	/*============================================================
	Public Methods
	============================================================*/
	
	/** Sets the branches of this choice dialogue sequence node. **/
	public void setBranches(SequenceNode[] branches) {
		this.branches = branches;
	}
	
	@Override public int branches() {
		if (branches == null)
			return 0;
		else
			return branches.length;
	}

	@Override public SequenceNode getBranch(int n) {
		return branches[n];
	}

	@Override public void onShowInput(AbstractDialogue dialogue) {};

	@Override public void onSelect(ChoiceDialogue dialogue) {
		getSequence().next(dialogue.getSelection());
	}

}
